<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib  prefix="html" uri="http://struts.apache.org/tags-html-el"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cerca File</title>
<link href="css/images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
				<!-- JAVASCRIPT USATI-->
<script type="text/javascript" src="../GestioneDocumentale/js/jquery-1.5.1.js"></script>
<script type="text/javascript" src="../GestioneDocumentale/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="../GestioneDocumentale/js/jquery.ui.datepicker.js"></script>
				<!-- FINE-JAVASCRIPT -->
				<!-- CSS USATI -->
<link rel="stylesheet" type="text/css" href="../GestioneDocumentale/css/jquery-ui-1.8.11.custom.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
				<!-- FINE CSS -->
		
<script>
	$(function() {
		$( "#dateiniziostring" ).datepicker();
	});
</script>
<script>
	$(function() {
		$( "#datefinestring" ).datepicker();
	});
</script>
<script type="text/javascript">

function checkForm(){
	var form = document.getElementById('formRicercaAvanzata');
	
	var dataInizioString = form.dataInizioString.value;
	var dataFineString = form.dataFineString.value;
	
	if(dataInizioString != '' && dataFineString != ''){
		var annoInizio = parseInt(dataInizioString.substring(6, 10),10);
		var meseInizio = parseInt(dataInizioString.substring(3, 5),10);
		var giornoInizio = parseInt(dataInizioString.substring(0, 2),10);
		
		var annoFine = parseInt(dataFineString.substring(6, 10), 10);
		var meseFine = parseInt(dataFineString.substring(3, 5), 10);
		var giornoFine = parseInt(dataFineString.substring(0, 2), 10);
		
		if(annoFine <= annoInizio && meseFine <= meseInizio && giornoFine <= giornoInizio){
			alert('le date non sono state inserite correttamente');
			return false;
		}
	}
	if(dataInizioString == '' && dataFineString != ''){
		alert('le date non sono state inserite correttamente');
		return false;
	}
	return true;
}
</script>
</head>
<body>
<jsp:include page="/header.jsp"></jsp:include>

<div id="sidebar">

	<jsp:include page="menuFile.jsp"></jsp:include>
	<ul>
		<li><html:link href="preparaGestioneFiles.do">Gestione File</html:link></li>
	</ul>
	
</div>
<div id="content">
	<html:errors/>
	<h3>Cerca File</h3>
	<form action="PrepareListaDocumentoAvanzataAction.do" method="post" id="formRicercaAvanzata">
		<div class="demo">
			<div class="form_p">
				<div class="row"><span class="label">Nome Documento</span><span
					class="formw"><input name="nomeDocumento" type="text"></span></div>
				
				<div class="row"><span class="label">Classificazione</span><span
					class="formw"><select name="idClassificazione">
										<option>-- Lista Classificazioni --</option>
										<c:forEach var="classificazione" items="${listaClassificazioni}">
											<option value="${classificazione.idClassificazione}">${classificazione.descrizione }-</option>
										</c:forEach>
									</select></span></div>
				
				<div class="row"><span class="label">Tag</span><span
					class="formw"><select name="idTag">
							<option>-- Lista Tags --</option>
							<c:forEach var="tag" items="${listaTag}">
								<option value="${tag.idTag}">${tag.descrizione }-</option>
							</c:forEach>
						</select></span></div>
				<div class="row">Data</div>
				<div class="row"><span class="label">Da:</span><span
					class="formw"><input id="dateiniziostring" name="dataInizioString" type="text" readonly="readonly"></span></div>
				<div class="row"><span class="label">A:</span><span
					class="formw"><input id="datefinestring" name="dataFineString" type="text" readonly="readonly"></span></div>
			</div>
		</div><!-- End demo -->
		
		<div style="display: none;" class="demo-description">
		<p>The datepicker is tied to a standard form input field.  Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay.  Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. If a date is chosen, feedback is shown as the input's value.</p>
		</div><!-- End demo-description -->
		
		<div class="row"><input type="reset" value="Reset"/>
		<input type="submit" value="Cerca" onclick="return checkForm();"></input></div>
	</form>
	<div class="row"><html:link href="preparaRicercaSemplice.do">Ricerca Semplice</html:link></div>
</div>

<jsp:include page="/footer.jsp"></jsp:include>
</body>
</html>